import {Injectable} from '@angular/core';
import {_HttpClient} from '@delon/theme';
import {Observable} from 'rxjs/Observable';
import {SignupSetting} from './signup-setting';

@Injectable()
export class SignupService {

    url_setting_list = 'Signup/info';
    url_setting_add = 'Signup/addinfo';
    url_setting_del = 'Signup/delsigninfo';
    url_setting_info = 'Signup/getSigninfo';

    url_signlist_list = 'Signup/getSignList';
    url_signlist_update = 'Signup/upsignup/';

    constructor(private http: _HttpClient) {
    }


    /**
     *  得到报名设置
     * @returns {Observable<any>}
     */
    settingList(): Observable<any> {
        return this.http.get(this.url_setting_list);
    }

    getSettingInfo(id: number): Observable<any> {
        return this.http.get(this.url_setting_info, {id: id});
    }

    addSetting(item: SignupSetting) {
        return this.http.post(this.url_setting_add, JSON.stringify(item));
    }

    delSignupSetting(id: any): Observable<any> {
        return this.http.delete(this.url_setting_del, {id: id});
    }

    getSignList(page: number): Observable<any> {
        return this.http.get(this.url_signlist_list, {page: page});
    }

    upSignUp(id: number) {
        return this.http.patch(this.url_signlist_update + id);
    }
}
